package crmdna.member;

import java.util.HashSet;
import java.util.Set;
import java.util.TreeSet;

public class MemberQueryCondition {
	String client;
	String searchStr;
	String email;
	Set<String> firstName3Chars = new TreeSet<>();
	Set<Long> groupIds = new HashSet<>();
	Set<Long> programIds = new HashSet<>();
	Set<Long> practiceIds = new HashSet<>();
	Set<Long> programTypeIds = new HashSet<>();
	int maxResultSize;
	
	public MemberQueryCondition(String client, int maxResultSize) {
		this.client = client;
		this.maxResultSize = maxResultSize;
	}	
	
	public MemberQueryCondition searchStr(String searchStr) {
		if (searchStr != null)
			searchStr = searchStr.toLowerCase();
		
		this.searchStr = searchStr;
		return this;
	}	
	
	public MemberQueryCondition email(String email) {
		if (email != null)
			email = email.toLowerCase();
		
		this.email = email;
		return this;
	}	
	
	public MemberQueryCondition groupIds(Set<Long> groupIds) {
		this.groupIds = groupIds;
		return this;
	}
	
	MemberQueryCondition groupId(long groupId) {
		this.groupIds.add(groupId);
		return this;
	}
	
	MemberQueryCondition firstName3Char(String firstName3Char) {
		this.firstName3Chars.add(firstName3Char);
		return this;
	}
	
	MemberQueryCondition firstName3Char(Set<String> firstName3Chars) {
		this.firstName3Chars.addAll(firstName3Chars);
		return this;
	}
	
	public MemberQueryCondition practiceIds(Set<Long> practiceIds) {
		this.practiceIds = practiceIds;
		return this;
	}
	
	public MemberQueryCondition practiceId(long practiceId) {
		this.practiceIds.add(practiceId);
		return this;
	}
	
	public MemberQueryCondition programIds(Set<Long> programIds) {
		this.programIds = programIds;
		return this;
	}
	
	public MemberQueryCondition programId(long programId) {
		this.programIds.add(programId);
		return this;
	}
	
	public MemberQueryCondition programTypeIds(Set<Long> programTypeIds) {
		this.programTypeIds = programTypeIds;
		return this;
	}
	
	public MemberQueryCondition programTypeId(long programTypeId) {
		this.programTypeIds.add(programTypeId);
		return this;
	}		
}
